--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Commit 6b014394fae7e4b3f4a6688a2d99266b31ff1102
Parents : fe7686c
Author : Mark Qvist <mark@unsigned.io>
Date : 2025-11-06T22:50:51+01:00
Added low-latency output mode switch to telephony primitive
Changes
2 files changed, 16 insertions(+), 7 deletions(-)
Diff
diff --git a/LXST/Platforms/android/soundcard.py b/LXST/Platforms/android/soundcard.py
index 5c0ad05..e685079 100644
--- a/LXST/Platforms/android/soundcard.py
+++ b/LXST/Platforms/android/soundcard.py
@@ -131,9 +131,9 @@ class _AndroidAudio:
self.available_devices.append(d)
# TODO: Remove debug
- RNS.log(f"Discovered audio devices:", RNS.LOG_DEBUG)
- for d in self.available_devices:
- RNS.log(f" {d}", RNS.LOG_DEBUG)
+ # RNS.log(f"Discovered audio devices:", RNS.LOG_DEBUG)
+ # for d in self.available_devices:
+ # RNS.log(f" {d}", RNS.LOG_DEBUG)
except Exception as e:
RNS.log(f"Error while initializing Android audio backend: {e}", RNS.LOG_ERROR)
@@ -566,7 +566,7 @@ class _Player(_Stream):
remaining_frame_samples = len(data)
written_samples = remaining_frame_samples
# TODO: Remove debug
- RNS.log(f"Buffer overrun. Target buffer samples {self._target_buffer_samples}. Needed to write {remaining_frame_samples} samples / {len(samples_bytes)} bytes. Discarding {written_samples} input samples.")
+ # RNS.log(f"Buffer overrun. Target buffer samples {self._target_buffer_samples}. Needed to write {remaining_frame_samples} samples / {len(samples_bytes)} bytes. Discarding {written_samples} input samples.")
data = data[written_samples:]
@@ -580,7 +580,7 @@ class _Player(_Stream):
delta = underruns-self._last_underruns
self._last_underruns = underruns
# TODO: Remove debug
- RNS.log(f"{delta} underruns on {self}")
+ # RNS.log(f"{delta} underruns on {self}")
class _Recorder(_Stream):
def __init__(self, *args, **kwargs):
diff --git a/LXST/Primitives/Telephony.py b/LXST/Primitives/Telephony.py
index 9ed78bd..5291fa4 100644
--- a/LXST/Primitives/Telephony.py
+++ b/LXST/Primitives/Telephony.py
@@ -77,6 +77,7 @@ class Telephone(SignallingReceiver):
self.speaker_device = None
self.microphone_device = None
self.ringer_device = None
+ self.low_latency_output = False
threading.Thread(target=self.__jobs, daemon=True).start()
RNS.log(f"{self} listening on {RNS.prettyhexrep(self.destination.hash)}", RNS.LOG_DEBUG)
@@ -134,6 +135,14 @@ class Telephone(SignallingReceiver):
self.ringtone_gain = gain
RNS.log(f"{self} ringtone set to {self.ringtone_path}", RNS.LOG_DEBUG)
+ def set_low_latency_output(self, enabled):
+ if enabled:
+ self.low_latency_output = True
+ RNS.log(f"{self} low-latency output enabled", RNS.LOG_DEBUG)
+ else:
+ self.low_latency_output = False
+ RNS.log(f"{self} low-latency output disabled", RNS.LOG_DEBUG)
+
def __jobs(self):
while self.destination != None:
time.sleep(self.JOB_INTERVAL)
@@ -251,7 +260,7 @@ class Telephone(SignallingReceiver):
self.__start_pipelines()
RNS.log(f"Call setup complete for {RNS.prettyhexrep(identity.hash)}", RNS.LOG_DEBUG)
if callable(self.__established_callback): self.__established_callback(self.active_call.get_remote_identity())
- self.audio_output.enable_low_latency()
+ if self.low_latency_output: self.audio_output.enable_low_latency()
return True
def hangup(self):
@@ -497,7 +506,7 @@ class Telephone(SignallingReceiver):
RNS.log(f"Call setup complete for {RNS.prettyhexrep(self.active_call.get_remote_identity().hash)}", RNS.LOG_DEBUG)
self.call_status = signal
if callable(self.__established_callback): self.__established_callback(self.active_call.get_remote_identity())
- self.audio_output.enable_low_latency()
+ if self.low_latency_output: self.audio_output.enable_low_latency()
def __str__(self):
return f"<lxst.telephony/{RNS.hexrep(self.identity.hash, delimit=False)}>"
\ No newline at end of file
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────